package example;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @Author: luobiao
 * @Date: 2024/3/10 12:11
 * @Description:
 */
@Aspect
public class MyAspect {
    // 定义切点
    @Pointcut("execution(* example..*(..))")
    public void myPointcut() {
        // 切点定义，无需方法体
    }

    // 定义前置通知
    @Before("myPointcut()")
    public void myAdvice(JoinPoint joinPoint) {
        System.out.println("Before " + joinPoint.getSignature());
    }

    // 定义后置通知
    @After("myPointcut()")
    public void afterAdvice(JoinPoint joinPoint) {
        System.out.println("After " + joinPoint.getSignature());
    }
}
